//
//  DFType.m
//  dfCommandBuilder
//
//  Created by Tom Booth on 15/06/2009.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "DFType.h"

@interface DFType (PrivateMethods)
	+ (NSUInteger)hashParams: (NSArray*) params;
@end


@implementation DFType

NSMutableDictionary *type_store;

@synthesize name;
@synthesize parameters;

- init {
	self = [super init];
	
	return self;
}


+ (DFType*)generateTypeFromParameters:(NSArray*) params {
	
	if (type_store == NULL) { type_store = [[NSMutableDictionary alloc] init]; }
	
	NSUInteger hash = [DFType hashParams:params];
	DFType *type = [type_store objectForKey:(id)hash];
	
	if (type==NULL) {
		// generate a type from the list of params
		type = [[DFType alloc] init];
		
		// set the name
		type.name = @"df_type";
		
		// list the parameters
		type.parameters = [[NSArray alloc] initWithArray:params copyItems:FALSE];
		
		// store it
		[type_store setObject:type forKey:(id)hash];
	}
	
	
	return type;
}

+ (NSUInteger)hashParams: (NSArray*) params {
	return 0;
}

@end
